package io.renren.modules.simida.controller;

import com.alibaba.fastjson.JSONObject;
import io.renren.common.utils.R;
import io.renren.modules.simida.service.UserDataService;
import io.renren.modules.simida.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Auther: miaoguoxin
 * @Date: 2019/11/21 17:53
 * @Description: 首页
 */
@RestController
@RequestMapping("simida/home")
public class HomeController {
    @Autowired
    private UserInfoService userInfoService;
    @Autowired
    private UserDataService userDataService;
    /**
     *  性别比例统计
     */
    @GetMapping("/gender_count")
    public R genderCount(){
        return R.ok().put("data", userInfoService.genderGroupCount());
    }

    /**
    * @Description: 时间段注册人数统计
    * @Param:
    * @return:
    * @Author: miaoguoxin
    * @Date: 2019/11/21
    */
    @GetMapping("/reg_num_count")
    public R regUserNumDaysCount(@RequestParam Map<String,Object> prams){
        return R.ok().put("data", userInfoService.regNumStatistics(prams));
    }

    /**
    * @Description: 注册设备号统计
    * @Param:
    * @return:
    * @Author: miaoguoxin
    * @Date: 2019/11/22
    */
    @GetMapping("/device_type_count")
    public R deviceTypeCount(){
       return R.ok().put("data",userDataService.queryCountGroupByDeviceType());
    }

    /**
    * @Description: 登陆版本统计
    * @Param:
    * @return:
    * @Author: miaoguoxin
    * @Date: 2019/11/22
    */
    @GetMapping("/version_count")
    public R versionCount(){
        return R.ok().put("data",userDataService.queryCountGroupByVersion());
    }
}
